Ext.define("app.system.config.form", {
	extend : 'Ext.window.Window',
	title : '编辑配置信息',
	height : 600,
	width : 800,
	closable : true,
	resizable : false,
	modal : true,
	constrain : true,
	plain : true,
	layout : {
		type : 'border'
	},
	initComponent : function() {
		var me = this;
		me.form = me.createForm();
		Ext.apply(me, {
			items : [ me.form ],
			buttons : [ {
				text : '确认',
				bodyStyle : 'padding:0 0 0 5px',
				handler : function() {
					me.submitForm();
				}
			}, {
				text : '关闭',
				bodyStyle : 'padding:0 0 0 5px',
				handler : function() {
					me.close();
				}
			} ]
		});
		me.callParent(arguments);
	},
	submitForm : function() {
		var me = this;
		var params = {
			configId : me.configId
		};
		evt.submit(me.form, systemUrl + '/boyon/config/modify', params,
				function() {
					Ext.Msg.alert('提示', '操作成功');
					me.parentTarget.reloadStore();
					me.close();
				});
	},
	loadData : function(form) {
		var me = this;
		var configId = me.configId;
		if (!configId) {
			return;
		}
		utils.loadform({
			form : me,
			model : 'app.system.model.config',
			url : systemUrl + '/boyon/config/find',
			extraParams : {
				'configId' : me.configId
			},
			fn : function(rec) {
				me.form.getForm().loadRecord(rec);
			}
		});
	},
	createForm : function() {
		var me = this;
		var fields = me.createField();
		var form = Ext.create('Ext.form.Panel', {
			layout : 'column',
			region : 'center',
			items : fields,
			listeners : {
				afterrender : function() {
					me.loadData(form);
				}
			}
		});
		return form;
	},
	createField : function() {
		var me = this;
		var array = new Array();
		utils.pushfieldarray(array, '1', {
			name : 'configName',
			beforeLabelTextTpl : required,
			fieldLabel : '配置名称',
			allowBlank : false,
			readOnly : true
		});
		utils.pushfieldarray(array, '1', {
			name : 'configKey',
			beforeLabelTextTpl : required,
			fieldLabel : '配置key',
			allowBlank : false,
			readOnly : true
		});
		utils.pushfieldarray(array, '1', {
			name : 'configValue',
			fieldLabel : '配置值',
			columnWidth : 1
		});
		return array;
	}
});